<%@ Language=VBScript %>
<%
	Session("bChucnang")=1
	Session("FormName")="F44"
%>
<!--#include file="..\CheckSession.inc"-->	
<!--#include file="..\Report.inc"-->
<%
	bchon=Request("bchon")
	sDieuKien=Request("sDieuKien")
	bdv=Request("bdv")
	if bchon="all" then
		if bdv="" then
			sSQL="Select vtden.*,ykxl_hxl.hanxuly, ykxl_hxl.nbdxuly,hoanthanhxl.ngayhtxl,hoanthanhxl.kqxl,donvi.tendonvi from VTDen inner join ykxl_hxl on vtden.id = ykxl_hxl.idvtden left outer join hoanthanhxl on ykxl_hxl.idvtden=hoanthanhxl.idvtden and ykxl_hxl.madonvi=hoanthanhxl.madonvi inner join donvi on ykxl_hxl.madonvi=donvi.madonvi where vtden.masotc in ('01','02.01','02.02','02.03','03','04.01','04.02','04.03','04.04','05.01','05.02','06','07.01','07.02','07.03','07.04','07.05','07.06','07.07','07.08') and vtden.congcong=0 and vtden.trangthaiduyet=1 "
			CAll RP("rptHanXuLyDonvi.rpt",sSQL)		
		else
			sSQL="Select vtden.*,ykxl_hxl.hanxuly, ykxl_hxl.nbdxuly,hoanthanhxl.ngayhtxl,hoanthanhxl.kqxl,donvi.tendonvi from VTDen inner join ykxl_hxl on vtden.id = ykxl_hxl.idvtden  left outer join hoanthanhxl on ykxl_hxl.idvtden=hoanthanhxl.idvtden and ykxl_hxl.madonvi=hoanthanhxl.madonvi inner join donvi on ykxl_hxl.madonvi=donvi.madonvi where ykxl_hxl.madonvi = '"& bdv &"' and vtden.masotc in ('01','02.01','02.02','02.03','03','04.01','04.02','04.03','04.04','05.01','05.02','06','07.01','07.02','07.03','07.04','07.05','07.06','07.07','07.08') and vtden.congcong=0 and vtden.trangthaiduyet=1 "& sDieuKien &" order by soghinhan DESC,ngaynhan desc"
			CAll RP("rptHanXuLy.rpt",sSQL)
		end if
	else
		sSQL="Select vtden.*,ykxl_hxl.hanxuly, ykxl_hxl.nbdxuly,hoanthanhxl.ngayhtxl,hoanthanhxl.kqxl,donvi.tendonvi from VTDen inner join ykxl_hxl on vtden.id = ykxl_hxl.idvtden  and ykxl_hxl.madonvi = '"& Session("bMaDonVi") &"' left outer join hoanthanhxl on ykxl_hxl.idvtden=hoanthanhxl.idvtden and ykxl_hxl.madonvi=hoanthanhxl.madonvi left outer join donvi on ykxl_hxl.madonvi=donvi.madonvi where  vtden.masotc in ('01','02.01','02.02','02.03','03','04.01','04.02','04.03','04.04','05.01','05.02','06','07.01','07.02','07.03','07.04','07.05','07.06','07.07','07.08') and vtden.congcong=0 and vtden.trangthaiduyet=1 "& sDieuKien &" order by soghinhan DESC,ngaynhan desc"
		CAll RP("rptHanXuLy.rpt",sSQL)
	end if
%><!-- #include file="SmartViewerActiveX.asp" -->
<%
	Conn.Close
	Set Conn=nothing
%>